<template>
	<view>
		<!-- 详情 -->
		<view class="description">
			<view class="content">
				<rich-text :nodes="descriptionStr"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	import Api from '@/common/api';
	export default {
		data() {
			return {
				imgsrc: Api.imgsrc,
				product_id: '',
				goods: [],
				//商品描述html
				descriptionStr: '<div style="text-align:center;"><img width="100%" src="https://ae01.alicdn.com/kf/HTB1t0fUl_Zmx1VjSZFGq6yx2XXa5.jpg"/><img width="100%" src="https://ae01.alicdn.com/kf/HTB1LzkjThTpK1RjSZFKq6y2wXXaT.jpg"/><img width="100%" src="https://ae01.alicdn.com/kf/HTB18dkiTbvpK1RjSZPiq6zmwXXa8.jpg"/></div>',
				
			};
		},
		async onLoad(option) {
			// #ifdef MP
			//小程序隐藏返回按钮
			this.showBack = false;
			// #endif
			//option为object类型，会序列化上个页面传递的参数
			this.product_id = option.product_id;
			if (this.product_id) {
				var parm_data = {
					'product_id': this.product_id
				}
				let cartList = uni.getStorageSync('cartList');
				let data = await Api.apiCall('post', Api.goods.goodsDetail, parm_data);
				if(data)
				{
					this.goods = data.good;
					var detail_img = this.goods.detail_html.split(',');
					var detail_html = '';
					for(var i = 0; i < detail_img.length; i++) {
						detail_html += '<img width="100%" src="' + Api.imgsrc + detail_img[i] + '"/>'
					}
					if(detail_html)
					{
						this.descriptionStr = '<div style="text-align:center;">' + detail_html + '</div>';
					}
				}
				
			}
		},
		
		mounted() {

		},
		methods: {
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f8f8f8;
	}
	.description {
		.title {
			width: 100%;
			height: 80upx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: $font-base + 4upx;
			color: #232323;
		}
		
	}

</style>
